package com.flexcloudsdk.xmpp;

import java.util.logging.Logger;

import com.flexcloudsdk.xmpp.CloudMessage;
import com.google.appengine.api.xmpp.MessageBuilder;
import com.google.appengine.api.xmpp.Message;
import com.google.appengine.api.xmpp.MessageType;
import com.google.appengine.api.xmpp.JID;


public class CloudMessageBuilder {
	private static final Logger log = Logger.getLogger(CloudMessageBuilder.class.getName());
	private MessageBuilder builder = null;
	
	public CloudMessageBuilder() {
		log.info("CloudMessageBuilder has been created by BlazeDS");
		builder = new MessageBuilder();
	}
	
	public CloudMessageBuilder asXml(boolean value) {
		builder =  builder.asXml(value);
		return this;
	}
	
	public CloudMessage build() {
		Message message = builder.build();
		CloudMessage cloudMessage = new CloudMessage();
		cloudMessage.setMessage(message);
		return cloudMessage;
	}
	
	public CloudMessageBuilder withBody(String body) {
		builder = builder.withBody(body);
		return this;
	}
	
	public CloudMessageBuilder withFromJid(JID fromJid) {
		builder = builder.withFromJid(fromJid);
		return this;
	}
	
	public CloudMessageBuilder withMessageType(MessageType type) {
		builder = builder.withMessageType(type);
		return this;
	}
	

}
